package cn.crce.cloud9.simple;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * @author OnCloud9
 * @description
 * @project NRCE-TEST
 * @date 2022年09月10日 上午 10:07
 */
public class Case29 extends JFrame{
    private JButton b;
    public Case29(String s){
        setTitle(s);
        b=new JButton("Hello");
        getContentPane().add(b);
        //*********Found********
        b.addActionListener( new HandleButton() );
        setSize(150,150);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        //*********Found********
        setVisible( true);
    }
    class HandleButton implements ActionListener {
        public void actionPerformed(ActionEvent e){
            //*********Found********
            if ( "Hello".equals(b.getText()) )
                b.setText("你好");
            else
                b.setText("Hello");
        }
    }
    public static void main(String args[]){
        //*********Found********
        new Case29("二级Java");
    }
}
